package com.whj.wkpt.mapper;

import com.whj.wkpt.entity.DeliveryAttachment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeliveryAttachmentMapper {
    
    DeliveryAttachment findById(Long attachmentId);
    
    List<DeliveryAttachment> findByApplicationId(Long applicationId);
    
    @Insert("INSERT INTO delivery_attachments(application_id, file_name, file_path, file_size, upload_time) " +
            "VALUES(#{applicationId}, #{fileName}, #{filePath}, #{fileSize}, #{uploadTime})")
    @Options(useGeneratedKeys = true, keyProperty = "attachmentId")
    int insert(DeliveryAttachment attachment);
    
    @Delete("DELETE FROM delivery_attachments WHERE attachment_id = #{attachmentId}")
    int deleteById(Long attachmentId);
    
    List<DeliveryAttachment> findAll();
}